package Year22_Month04.day20;

public class 移除链表元素 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode node = new ListNode(0);
        ListNode tmp = node;
        node.next = head;
        while (tmp.next != null){
            if(tmp.next.val == val){
                tmp.next = tmp.next.next;
            }else{
                tmp = tmp.next;
            }
        }
        return node.next;
    }
}
